<template>
  <div class="view-container workOvertimeList">
    <header class="view-header">
      <div class="header-container">
        <div class="header-title">
          <i class="el-icon-s-grid"></i>
          <span>外出管理</span>
        </div>
        <div class="header-form">
          <!--更多-->
<!--          <div class="header-form-item">
            <el-dropdown @command="handleCommand">
              <el-button type="default" :loading="delLoading">
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item icon="el-icon-refresh-right" class="color-refresh-item" command="refresh">刷新
                </el-dropdown-item>
                <el-dropdown-item icon="el-icon-edit" class="color-edit-item" command="edit">编辑</el-dropdown-item>
                <el-dropdown-item icon="el-icon-delete" class="color-del-item" command="del">{{isBatchesDel}}
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>-->
<!--          <div class="header-form-item">
            <el-button icon="el-icon-refresh-right" @click="refresh">刷新</el-button>
          </div>-->
          <div class="header-form-item">
            <el-button icon="el-icon-edit" @click="openEditDialog(true)">编辑</el-button>
          </div>
          <div class="header-form-item">
            <el-button type="danger" :loading="delLoading" icon="el-icon-delete" @click="del">{{isBatchesDel}}</el-button>
          </div>
          <!--搜索-->
<!--          <div class="header-form-item">
            <el-button type="primary" icon="el-icon-search" @click="fetchData">查询</el-button>
          </div>-->
          <div class="header-form-item">
            <el-button type="success" icon="el-icon-notebook-2" @click="openEditDialog(false)">外出申请</el-button>
          </div>
        </div>
      </div>
    </header>

<!--    <view-header
      @refresh="refresh"
      @edit="edit"
      :delLoading="delLoading"
      :isBatchesDel="isBatchesDel"
      :title="'外出管理'"
      :applyLabel="'外出申请'"
      @del="del"
      @fetchData="fetchData"
      @openDialog="openDialog"
    ></view-header>-->

    <section>
      <el-table
        ref="table"
        :data="tableData"
        border
        stripe
        @selection-change="handleSelectionChange"
        @row-click="handleRowClick"
      >
        <el-table-column type="selection" align="center"/>
        <el-table-column prop="waiChuRenName" label="申请人" align="center" width="100"/>
        <el-table-column prop="waiChuShiYou" label="事由" align="left" >
          <template slot-scope="s">
            <el-link @click="showDetail(s.row.waiChuId)">{{s.row.waiChuShiYou}}</el-link>
          </template>
        </el-table-column>
        <el-table-column sortable prop="startTime" label="开始时间" :formatter="startTimeFmt" align="center" width="150"/>
        <el-table-column sortable prop="endTime" label="结束时间" align="center" :formatter="endTimeFmt" width="150"/>
        <el-table-column prop="isCar" label="是否带车" align="center" width="100"/>
        <el-table-column sortable prop="stateName" label="状态" align="center" width="100">
          <template slot-scope="s">
            <el-tag :type="switchType(s.row.stateName)">{{s.row.stateName}}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </section>

    <footer>
      <el-pagination
        :page-sizes="[10, 20, 50, 100]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
        :page-size="page.size"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </footer>

    <wai-chu-save ref="save-page" @update="fetchData"></wai-chu-save>
  </div>
</template>

<script>
  import waiChuAPI from '@/api/waiChu/waiChu'
  import waiChuSave from './WaiChuSave'
  import listMixin from '@/mixin/listMixin'
  import flowManagerListMixin from '@/mixin/flowManagerListMixin'
/*  import ViewHeader from '@/common/FlowManagerListHeader'*/
  export default {
    name: 'WaiChuList',
    components:{waiChuSave},
    mixins: [listMixin,flowManagerListMixin],
    data() {
      return {
        waiChu: {
          endTime: "",
          startTime: "",
          stateName: "",
          waiChuId: "",
          waiChuRenId: '',
          waiChuRenName: "",
          waiChuShiYou: ""
        },
        mixinParams: {
          addUrl: '',
          editUrl: '',
          propertyName: 'qingJiaId',
          API: waiChuAPI
        }
      }
    },
    created() {
    },
    computed: {
    },
    methods: {
      showDetail(id){
        this.$router.push('/work-waichu/approval-detail/'+id+'/'+false)
      },
      update(){
/*        if(this.tableData.length === this.page.size){
          this.page.index++
        }*/
        this.fetchData()
      },
      fetchData() {
        waiChuAPI.list(this.page).then(res => {
          this.tableData = res.records
          this.page.total = res.total
        })
      },
      startTimeFmt(row){
        return this._util.format(row.startTime)
      },
      endTimeFmt(row){
        return this._util.format(row.endTime)
      }
    }
  }
</script>

<style lang="scss">

  .workOvertimeList {
    .el-dialog {
      width: 40%;
      .el-dialog__footer {
          padding: 10px 45px;
      }
    }
  }

</style>

